package com.pizza.gui;

import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;

import org.hibernate.Session;

import com.pizza.adapter.AdapterListPizzeria;
import com.pizza.spring.rmi.Produkt;
import com.pizza.spring.rmi.SessionFactoryUtil;

public class PizzeriaGui extends JFrame{
	JScrollPane scrollPane = new JScrollPane();
	 public JScrollPane getScrollPane() {
		return scrollPane;
	}
	 AdapterListPizzeria adapter ;
	public void setAdapter(AdapterListPizzeria adapter) {
		this.adapter = adapter;
	}
	public PizzeriaGui() {//Interfejs servera
		 scrollPane.setHorizontalScrollBarPolicy(
		            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		    scrollPane.setVerticalScrollBarPolicy(
		            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);
		Session session;
		session = SessionFactoryUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        ArrayList<Produkt> lista = new ArrayList<Produkt>();//= (ArrayList<Produkt>) session.createQuery("from Produkt").list();
        session.getTransaction().commit();
		adapter= new AdapterListPizzeria(this,10000, 10000,lista );
		adapter.setSize(10000, 10000);
		adapter.setVisible(true);
		scrollPane.setSize(10000, 10000);
		scrollPane.setViewportView(adapter);
		
	    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    pack();
	   
	    setLocation(500, 100);
	    setSize(600, 435);
	    setVisible(true);
		
	}
	public AdapterListPizzeria getAdapter() {
		return adapter;
	}
}
